package com.yj.rabbitClient.config;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RabbitMQPublish {

    @Autowired
    RabbitTemplate rabbitTemplate;


    @GetMapping("/sendApple")
    public String sendMessageToApple(String message){

        rabbitTemplate.convertAndSend("exchange-topic","apple",message);

        return "send apple success!";
    }

    @GetMapping("/sendBanana")
    public String sendMessageToBanana(String message){
        rabbitTemplate.convertAndSend("exchange-topic","banana",message);
        return "send banana success!";
    }

}
